package com.project.controller;

import com.project.bean.BuyerCarBean;
import com.project.bean.ProductBean;
import com.project.mapper.IBuyerCarMapper;
import com.project.service.IBuyerCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("buyerCar")
public class BuyerCarController {
    @Autowired
    private IBuyerCarService buyerCarService;

    @RequestMapping("findByUserId")
    public List<BuyerCarBean> findByUserId(Integer userId) {
        return buyerCarService.findByUserId(userId);
    }

    @RequestMapping("update")
    public String update(Integer buyerCarId, Integer num) {
        buyerCarService.update(buyerCarId, num);
        return "ok";
    }

    @RequestMapping("del")
    public String del(Integer buyerCarId) {
        buyerCarService.del(buyerCarId);
        return "ok";
    }

    @RequestMapping("add")
    public String add(String option, ProductBean product, Integer unm, Integer userId) {
        buyerCarService.add(option, product, unm, userId);
        return "ok";
    }
}
